package com.haierCamera.customapplication.api;

import com.haierCamera.customapplication.api.vo.AddDeviceResponse;
import com.haierCamera.customapplication.api.vo.ConfigDeviceResponse;
import com.haierCamera.customapplication.api.vo.GetAlarmSwitchResponse;
import com.haierCamera.customapplication.api.vo.GetCameraStatus;
import com.haierCamera.customapplication.api.vo.GetDeviceEntity;
import com.haierCamera.customapplication.api.vo.GetPushEntity;
import com.haierCamera.customapplication.api.vo.GetSystemRecord;
import com.haierCamera.customapplication.api.vo.GetUserAddress;
import com.haierCamera.customapplication.api.vo.GetUserInfoResponse;
import com.haierCamera.customapplication.api.vo.LoginResponse;
import com.haierCamera.customapplication.api.vo.TXOauth;
import com.haierCamera.customapplication.api.vo.Token;
import com.haierCamera.customapplication.api.vo.UpLoadCoverPictureResponse;

import java.util.List;

import androidx.lifecycle.LiveData;

import okhttp3.RequestBody;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Query;
import retrofit2.http.Url;

/**
 * @author yawei
 * @data on 2018/7/16 上午9:58
 * @email zyawei@live.com
 */
public interface ApiService {

    /******************************************** 设备相关 *************************************/
    //获取摄像头令牌
    @GET("api/device/camera/token")
    LiveData<ApiResult<Object>> getLcToken();

    //添加并绑定
    @POST("api/device/add/and/bind")
    LiveData<ApiResult<AddDeviceResponse>> addAndBind(
            @Query("serialNumber") String serialNumber
            , @Query("securityCode") String securityCode
    );

    //账号关联设备
    @POST("api/device/data/list")
    LiveData<ApiResult<List<GetDeviceEntity>>> getDevice();

    //删除并解绑账号关联设备
    @POST("api/device/del/and/unbind")
    LiveData<ApiResult<Object>> unbind(
            @Query("accountDeviceId") long accountDeviceId);

    //修改设备名称
    @POST("api/device/modify/name")
    LiveData<ApiResult<Object>> modifyame(
            @Query("accountDeviceId") long accountDeviceId,
            @Query("name") String name);

    //删除报警信息
    @POST("api/device/delete/alarm/message")
    LiveData<ApiResult<Object>> deleteAlarmMsg(
            @Query("indexId") String indexId,
            @Query("serialNumber") String serialNumber,
            @Query("channelNo") String channelNo);

    //上传视频封面
    @FormUrlEncoded
    @POST("api/device/upload/cover/picture")
    LiveData<ApiResult<UpLoadCoverPictureResponse>> upLoadCoverPic(
            @Field("pictureData") String pictureData,
            @Field("serialNumber") String serialNumber,
            @Field("channel") String channel);

    //获取单个报警开关
    @GET("api/device/gain/alarm/switch")
    LiveData<ApiResult<GetAlarmSwitchResponse>> getAlarmSwitch(
            @Query("serialNumber") String serialNumber
    );

    //设置单个报警开关
    @FormUrlEncoded
    @POST("api/device/set/alarm/switch")
    LiveData<ApiResult<Object>> setAlarmSwitch(
            @Field("serialNumber") String serialNumber
            , @Field("switchValue") int switchValue
    );

    /********************************************************************************************/

    //注册
    @FormUrlEncoded
    @POST("api/account/register")
    LiveData<ApiResult<Object>> getRegister(@Field("mobile") String mobile, @Field("vcode") String vcode, @Field("pwd") String pwd);

    //发送验证码
    @GET("api/account/vcode")
    LiveData<ApiResult<Object>> getVcode(@Query("mobile") String mobile);

    //忘记密码
    @FormUrlEncoded
    @POST("api/account/forgot/pwd")
    LiveData<ApiResult<Object>> forget(@Field("mobile") String mobile, @Field("vcode") String vcode, @Field("newPwd") String newPwd);

    //登录
    @FormUrlEncoded
    @POST("api/account/login")
    LiveData<ApiResult<LoginResponse>> login(@Field("mobile") String mobile, @Field("pwd") String pwd);

    //获取用户信息
    @GET("api/account/details")
    LiveData<ApiResult<GetUserInfoResponse>> getUserInfo();

    //上传头像
    @FormUrlEncoded
    @POST("api/account/upload/head")
    LiveData<ApiResult<Object>> upHead(@Field("head") String head);

    //公用的上传图片
    @POST()
    LiveData<ApiResult<String>> publicUpImage(@Url String uri, @Body RequestBody body);

    //修改昵称
    @FormUrlEncoded
    @POST("api/account/modify/nickname")
    LiveData<ApiResult<Object>> setNickname(@Field("nickName") String nickName);

    //验证原始手机号
    @FormUrlEncoded
    @POST("api/account/verify/original/mobile")
    LiveData<ApiResult<Object>> checkPhone(@Field("vcode") String vcode);

    //更换手机号
    @FormUrlEncoded
    @POST("api/account/modify/mobile/phone")
    LiveData<ApiResult<Object>> setPhone(@Field("newMobile") String newMobile, @Field("vcode") String vcode);

    //修改密码
    @FormUrlEncoded
    @POST("api/account/modify/pwd")
    LiveData<ApiResult<Object>> setPwd(@Field("oldPwd") String oldPwd, @Field("newPwd") String newPwd);

    //意见反馈
    @FormUrlEncoded
    @POST("api/account/feed/back")
    LiveData<ApiResult<Object>> feedBack(@Field("text") String text, @Field("mobileMail") String mobileMail);

    @POST("api/account/logout")
    LiveData<ApiResult<Object>> logout();

    //获取系统消息
    @GET("api/information/system/message")
    LiveData<ApiResult<GetSystemRecord>> getSystemMsg(@Query("page") int page, @Query("pageSize") int pageSize);

    //获取个人消息
    @GET("api/information/personal/push")
    LiveData<ApiResult<GetSystemRecord>> getUserMsg(@Query("page") int page, @Query("pageSize") int pageSize);

    //获取推送配置
    @GET("api/account/push/config")
    LiveData<ApiResult<GetPushEntity>> getSendSetting();

    //设置推送配置
    @FormUrlEncoded
    @POST("api/account/set/push/config")
    LiveData<ApiResult<Object>> setSendSetting2(@Field("pushState") int pushState);

    //设置推送配置
    @FormUrlEncoded
    @POST("api/account/set/push/config")
    LiveData<ApiResult<Object>> setSendSetting(@Field("pushState") int pushState
            , @Field("startTime") String startTime
            , @Field("endTime") String endTime);

    //获取地址
    @GET("api/account/gain/address")
    LiveData<ApiResult<GetUserAddress>> getUserAddress();

    //设置地址
    @FormUrlEncoded
    @POST("api/account/set/address")
    LiveData<ApiResult<Object>> setUserAddress(@Field("address") String address, @Field("contactMan") String contactMan, @Field("contactNumber") String contactNumber);


    //B保修
    @FormUrlEncoded
    @POST("api/device/repair")
    LiveData<ApiResult<Object>> setRepair(@Field("serialNumber") String serialNumber, @Field("cause") String cause, @Field("address") String address, @Field("contactMan") String contactMan, @Field("contactNumber") String contactNumber);

    //注册推送
    @FormUrlEncoded
    @POST("api/account/register/push/client")
    LiveData<ApiResult<Object>> registerSend(@Field("clientBrand") String clientBrand, @Field("clientToken") String clientToken);

    //第三方授权
    @FormUrlEncoded
    @POST("api/account/oauth/thrid/part")
    LiveData<ApiResult<TXOauth>> oauth(@Field("oauthType") String oauthType, @Field("oauthCode") String oauthCode, @Field("nick") String nick, @Field("head") String head);

    //授权绑定账户
    @FormUrlEncoded
    @POST("api/account/oauth/binding/account")
    LiveData<ApiResult<Token>> bindingWX(@Field("oauthCode") String oauthCode, @Field("mobile") String mobile, @Field("vcode") String vcode);

    //解除绑定账户
    @FormUrlEncoded
    @POST("api/account/oauth/un/binding/account")
    LiveData<ApiResult<Object>> removeWX(@Field("oauthCode") String oauthType);

    //获取设备使能开关状态
    @GET("api/device/get/device/camera/status")
    LiveData<ApiResult<GetCameraStatus>> getCameraStatus(@Query("serialNumber") String serialNumber
            , @Query("channelNo") String channelNo, @Query("enableType") String enableType);

    //设置设备使能开关
    @FormUrlEncoded
    @POST("api/device/set/device/camera/status")
    LiveData<ApiResult<Object>> setCameraStatus(@Field("serialNumber") String serialNumber, @Field("channelNo") String channelNo,
                                                @Field("enableType") String enableType, @Field("enable") String enable);

    //识别设备热点
    @GET("api/device/need/ap/config/device")
    LiveData<ApiResult<List<ConfigDeviceResponse.item>>> configDevice();

    //配置动检计划
    @FormUrlEncoded
    @POST("api/device/modify/device/alarm/plans")
    LiveData<ApiResult<Object>> modifyAlarmPlans(@Field("serialNumber") String serialNumber,
                                                 @Field("channelNo") String channelNo,
                                                 @Field("period") String period,
                                                 @Field("beginTime") String beginTime,
                                                 @Field("endTime") String endTime);

}
